function [momentsScaled,nameMomentsScaled] = getScaledMoments(moments,ny,autoLagsIdx)

momentsScaled = zeros(size(moments,1),1);

% Mean values
idxMom       = 0;
Ey           = moments(1:ny,1);

% Eyy
Eyy          = zeros(ny,ny);
idxMom       = idxMom + ny;
for i=1:ny
    for j=i:ny
        idxMom = idxMom + 1;
        Eyy(i,j) = moments(idxMom,1);
        if i ~= j
            Eyy(j,i) = Eyy(i,j);
        end
    end
end
varY = Eyy-Ey*Ey';

% Standard deviations
stdY = sqrt(diag(varY));

% Cont. cross-correlations
crossCorr = zeros(ny*(ny+1)/2 - ny,1);
idx = 0;
for i=1:ny
    for j=i+1:ny
        idx = idx + 1;
        crossCorr(idx,1) = varY(i,j)/(stdY(i,1)*stdY(j,1));
    end
end

% Auto-correlations
maxNumLags = max(autoLagsIdx);
numLags    = size(autoLagsIdx,2);
autoCorr   = zeros(ny,numLags);
idx = 1;
for i=1:maxNumLags
    if i == autoLagsIdx(1,idx)
        autoCorr(:,idx) = (moments(idxMom+1:idxMom+ny,1)-moments(1:ny).^2)./stdY.^2;    
        idx    = idx + 1;
        idxMom = idxMom + ny;
    end
end

% Collecting the scaled moments
momentsScaled(1:ny,1)      = Ey;
momentsScaled(ny+1:2*ny,1) = stdY;

for i=1:numLags
    momentsScaled(2*ny+1+(i-1)*ny:2*ny+i*ny,1) = autoCorr(:,i);
end
momentsScaled(2*ny+numLags*ny+1:end,1) = crossCorr;

if nargout > 1
    % We construct a cell with general labels of the moments
    for i=1:ny
        nameMomentsScaled{i} = ['mean(',num2str(i),')      '];
    end
    idxMom = ny;
    for i=1:ny
        idxMom = idxMom + 1;
        nameMomentsScaled{idxMom} = ['std(',num2str(i),')       '];
    end
    for j=1:numLags
        for i=1:ny
            idxMom = idxMom + 1;
            nameMomentsScaled{idxMom} = ['autoCorr_',num2str(j)','(',num2str(i),')'];
        end
    end
    for i=1:ny
        for j=i+1:ny
            idxMom = idxMom + 1;
            nameMomentsScaled{idxMom} = ['corr(',num2str(i),',',num2str(j),')    '];
        end
    end
end


end